<?php
/**
 * Created by PhpStorm.
 * User: xiaomage
 * Date: 2020/12/15
 * Time: 10:43
 */

namespace common;


class ApiError
{
    protected static $instance = null;

    private $code = '';

    private $message = '';

    protected function __construct()
    {

    }

    protected function __clone()
    {

    }

    /**
     * @return ApiError|null
     */
    public static function instance()
    {
        if (!self::$instance) {
            self::$instance = new self();
        }

        return self::$instance;
    }

    /**
     * @param null $code
     * @return $this|string
     */
    public function code($code = null)
    {
        if ($code !== null) {
            $this->code = $code;
            return $this;
        } else {
            return $this->code;
        }
    }

    /**
     * @param null $message
     * @return $this|string
     */
    public function message($message = null)
    {
        if ($message !== null) {

            $this->message = $message;

            return $this;

        } else {

            return $this->message;
        }
    }
}